package cn.jinjimi.app.store;

import android.database.sqlite.SQLiteDatabase;

import cn.jinjimi.app.store.dao.ArticleDao;
import cn.jinjimi.app.store.dao.CacheDao;
import cn.jinjimi.app.store.dao.ClueEntityDao;
import cn.jinjimi.app.store.dao.ContactInfoDao;
import cn.jinjimi.app.store.dao.CustomerDao;
import cn.jinjimi.app.store.dao.LastFollowDao;
import cn.jinjimi.app.store.dao.NoticeEntityDao;
import cn.jinjimi.app.store.dao.ZdbProductAllDao;
import cn.jinjimi.app.store.dao.ZdbProductComDao;

import de.greenrobot.dao.AbstractDaoMaster;
import de.greenrobot.dao.AbstractDaoSession;
import de.greenrobot.dao.identityscope.IdentityScopeType;

/**
 * Created by Jinsen on 16/1/20.
 */
public class DaoMaster extends AbstractDaoMaster {

    public DaoMaster(SQLiteDatabase db, int schemaVersion) {
        super(db, schemaVersion);
        this.registerDaoClass(ArticleDao.class);
        this.registerDaoClass(CacheDao.class);
        this.registerDaoClass(CustomerDao.class);
        this.registerDaoClass(ZdbProductAllDao.class);
        this.registerDaoClass(ZdbProductComDao.class);
        this.registerDaoClass(NoticeEntityDao.class);
        this.registerDaoClass(ClueEntityDao.class);
        this.registerDaoClass(LastFollowDao.class);
        this.registerDaoClass(ContactInfoDao.class);
    }

    @Override
    public AbstractDaoSession newSession() {
        return newSession(IdentityScopeType.Session);
    }

    @Override
    public AbstractDaoSession newSession(IdentityScopeType type) {
        return new DaoSession(this.db, type, daoConfigMap);
    }

    /**
     * 创建数据表
     *
     * @param db
     */
    public static void createTable(SQLiteDatabase db) {
        ArticleDao.createTable(db, true);
        CacheDao.createTable(db, true);
        CustomerDao.createTable(db, true);
        ZdbProductAllDao.createTable(db, true);
        ZdbProductComDao.createTable(db, true);
        NoticeEntityDao.createTable(db, true);
        ClueEntityDao.createTable(db, true);
        LastFollowDao.createTable(db, true);
        ContactInfoDao.createTable(db, true);
    }

}
